package com.things8.iot.consumer.controller;

import com.things8.iot.common.result.GlobalResult;
import com.things8.iot.consumer.dto.QueryDeviceDto;
import com.things8.iot.consumer.feign.DeviceClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/5/17 22:16
 */
@RestController
@RequestMapping("test")
public class TestController {
    private static final Logger logger = LoggerFactory.getLogger(TestController.class);

    @Autowired
    private DeviceClient deviceClient;

    @GetMapping("test")
    public GlobalResult get(@RequestParam(name = "name",required = false,defaultValue = "8")String name) {
        logger.info("name :{}", name);

        QueryDeviceDto queryDeviceDto = new QueryDeviceDto();
        queryDeviceDto.setSearchContent(name);
        return deviceClient.pageList(queryDeviceDto);
    }
}
